package com.lj.back.manage.scaffold.module.sys.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.lj.back.manage.scaffold.common.response.R;
import com.lj.back.manage.scaffold.common.util.CommonUtil;
import com.lj.back.manage.scaffold.module.sys.DTO.SysLogDTO;
import com.lj.back.manage.scaffold.module.sys.DTO.SysLogPageQuery;
import com.lj.back.manage.scaffold.module.sys.VO.SysLogVO;
import com.lj.back.manage.scaffold.module.sys.service.SysLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lv
 * @version 1.0.0
 */
@RestController
@RequestMapping("/sys/log")
@Api(tags = "后台管理---业务日志模块")
@ApiSupport(author = "lv")
@AllArgsConstructor
public class SyslogController {

    private final SysLogService sysLogService;

    @GetMapping("/list")
    @ApiOperation(value = "分页查询业务日志列表")
    @ApiOperationSupport(order = 1)
    @RequiresPermissions("sys:log:sys:list")
    public R<Object> listSysLogs(@Validated SysLogPageQuery pageQuery){
        IPage<SysLogDTO> page = sysLogService.listSysLogs(pageQuery);
        IPage<SysLogVO> logVoPage = CommonUtil.pageBeanConvert(page, SysLogVO.class);
        return R.success(logVoPage);
    }
}
